from pyecharts import options as opts
from pyecharts.faker import Faker
from pyecharts.render import make_snapshot
from snapshot_phantomjs import snapshot

from pyecharts.charts import Pie

data = [
    list(z)
    for z in zip(
        Faker.choose() ,Faker.values()
        )
]
print(data)

def pie_chart() -> Pie:
    # ********* Begin *********#
    pie = (
        Pie()
    .add("",data,center=["40%", "50%"])
    .set_global_opts(
        title_opts=opts.TitleOpts(title="Pie-Legend 滚动"),
        legend_opts=opts.LegendOpts(type_="scroll", pos_left="80%", orient="vertical"),
    )
    .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
    )
    # ********** End **********#
    return pie

# make_snapshot(snapshot, pie_chart().render("render3.html"), "student_answer.png") # 输出图片
